SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE dbo.DnnProduct_GetPortalDesktopModules
	@PortalId int,
	@DesktopModuleId int

AS
	SELECT DnnProduct_PortalDesktopModules.*,
		   PortalName,
		   FriendlyName
	FROM   DnnProduct_PortalDesktopModules
		INNER JOIN DnnProduct_vw_Portals ON DnnProduct_PortalDesktopModules.PortalId = DnnProduct_vw_Portals.PortalId
		INNER JOIN DnnProduct_DesktopModules ON DnnProduct_PortalDesktopModules.DesktopModuleId = DnnProduct_DesktopModules.DesktopModuleId
	WHERE  ((DnnProduct_PortalDesktopModules.PortalId = @PortalId) OR @PortalId is null)
		AND    ((DnnProduct_PortalDesktopModules.DesktopModuleId = @DesktopModuleId) OR @DesktopModuleId is null)
	ORDER BY DnnProduct_PortalDesktopModules.PortalId, DnnProduct_PortalDesktopModules.DesktopModuleId

GO
